package ctrl;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import org.primefaces.model.UploadedFile;

/**
 *
 * @author Viktor
 */
@ManagedBean(name="photoUploadControllerBean")
@RequestScoped
public class PhotoUploadControllerBean {  
      
    private List<String> photos = new ArrayList<String>();
    private UploadedFile file;
  
    public void upload() {  
        FacesMessage msg = new FacesMessage("Succesful", file.getFileName() + " is uploaded.");  
        FacesContext.getCurrentInstance().addMessage(null, msg); 
        
        addPhoto(file.getFileName());  
    }

    public UploadedFile getFile() {
        return file;
    }

    public void setFile(UploadedFile file) {
        this.file = file;
    }
    
    public void addPhoto(String fileName) {
        photos.add(fileName);
    }

    public List<String> getPhotos() {
        return photos;
    }

    public void setPhotos(List<String> photos) {
        this.photos = photos;
    }
    
    
}